package com.glodon.paas.account.biz.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.glodon.paas.account.biz.UserAdviceReplyBiz;
import com.glodon.paas.account.dao.UserAdviceReplyDao;
import com.glodon.paas.account.dao.domain.UserAdviceReplyEntity;
import com.glodon.paas.util.UUIDUtil;

@Component("userAdviceReply")
public class UserAdviceReplyBizImpl implements UserAdviceReplyBiz{
	@Autowired
	private UserAdviceReplyDao userAdviceReplyDao;

	@Override
	public int deleteByPrimaryKey(String id) {
		return userAdviceReplyDao.deleteByPrimaryKey(id);
	}

	@Override
	public UserAdviceReplyEntity insert(UserAdviceReplyEntity record) {
		if(record.getId() == null){
			record.setId(UUIDUtil.getUUIDStr());
		}
		
		record.setCreateTime(new Date());
		record.setUpdateTime(record.getCreateTime());
		
		userAdviceReplyDao.insert(record);
		return record;
	}

	@Override
	public UserAdviceReplyEntity selectByPrimaryKey(String id) {
		return userAdviceReplyDao.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKey(UserAdviceReplyEntity record) {
		return userAdviceReplyDao.updateByPrimaryKey(record);
	}

	@Override
	public List<UserAdviceReplyEntity> selectByAdviceId(String id,Integer startIndex, Integer count) {
		if(startIndex == null || startIndex.intValue() < 0){
			startIndex =0;
		}
		if(count == null){
			count = 10;
		}		
		return userAdviceReplyDao.selectByAdviceId(id, startIndex, count);
	}
    
}
